package cn.orangeframe.neon.ui.advice;

import cn.orangeframe.neon.ui.model.Response;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.MessageSource;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @Resource
    private MessageSource messageSource;

    @ExceptionHandler(Exception.class)
    public Response handleAllExceptions(Exception ex) {
        log.error(ex.getMessage(), ex);
        return Response.failed(ex.getMessage());
    }
}
